package com.example.service;

import com.example.entity.Notes;
import com.example.entity.Options;
import com.example.mapper.OptionsMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
问题选项业务处理
 */
@Service
public class OptionsService {

    @Resource
    private OptionsMapper optionsMapper;

    public void add(Options options) {
        optionsMapper.insert(options);
    }

    public void deleteById(Integer id) {
        optionsMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(Options options) {
        optionsMapper.updateById(options);
    }

    public Options selectById(Integer id) {
        return optionsMapper.selectById(id);
    }

    public List<Options> selectAll(Options options) {
        return optionsMapper.selectAll(options);
    }

    public PageInfo<Options> selectPage(Options options, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Options> optionsList = optionsMapper.selectAll(options);
        return PageInfo.of(optionsList);
    }
}
